// string_utils.cpp - 字符串工具模块实现
module string_utils;

namespace StringUtils {
    std::string to_upper(const std::string& str) {
        std::string result = str;
        std::transform(result.begin(), result.end(), result.begin(), ::toupper);
        return result;
    }
    
    std::string to_lower(const std::string& str) {
        std::string result = str;
        std::transform(result.begin(), result.end(), result.begin(), ::tolower);
        return result;
    }
    
    std::vector<std::string> split(const std::string& str, char delimiter) {
        std::vector<std::string> tokens;
        std::string token;
        
        for (char c : str) {
            if (c == delimiter) {
                if (!token.empty()) {
                    tokens.push_back(token);
                    token.clear();
                }
            } else {
                token += c;
            }
        }
        
        if (!token.empty()) {
            tokens.push_back(token);
        }
        
        return tokens;
    }
    
    std::string join(const std::vector<std::string>& strings, const std::string& separator) {
        if (strings.empty()) return "";
        
        std::string result = strings[0];
        for (size_t i = 1; i < strings.size(); ++i) {
            result += separator + strings[i];
        }
        return result;
    }
    
    // TextProcessor 类实现
    TextProcessor::TextProcessor(const std::string& text_prefix) : prefix(text_prefix) {}
    
    std::string TextProcessor::process(const std::string& text) {
        return prefix.empty() ? text : prefix + ": " + text;
    }
    
    void TextProcessor::set_prefix(const std::string& new_prefix) {
        prefix = new_prefix;
    }
}
